/*
 * Copyright 2013-2019 Xia Jun(3979434@qq.com).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ***************************************************************************************
 *                                                                                     *
 *                        Website : http://www.farsunset.com                           *
 *                                                                                     *
 ***************************************************************************************
 */
package com.farsunset.lvxin.mvc.controller.dashboard;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.Objects;

@Controller
public class NavigationController {

	@Value("${system.manager.account}")
	private String account ;

	@Value("${system.manager.password}")
	private String password ;



	@GetMapping("/")
	public String index(){
		return "index";
	}

	@GetMapping("/login")
	public String login(){
		return "login";
	}

	@PostMapping("/login.do")
	public @ResponseBody int login(String account, String password, HttpServletRequest request){
		if(Objects.equals(account, this.account) && Objects.equals(password, this.password)) {
			request.getSession().setAttribute("manager", account);
			return 200;
		}
		return 403;
	}

	@GetMapping(value = "/dashboard")
	public String dashboard() {
		return "dashboard/index";
	}

	@GetMapping(value = "/webclient")
	public String webclient() {
		return "dashboard/webclient/index";
	}
}
